Skip to content

fix: treat invalid or missing dashboard timestamps as stale - #288

Merged
karagozemin merged 1 commit into
Sub-Rosa-Issue:mainfrom
ASIDISG:fix/issue-281-dashboard-timestamp-staleness
Aug 31, 2026
Merged

fix: treat invalid or missing dashboard timestamps as stale#288
karagozemin merged 1 commit into
Sub-Rosa-Issue:mainfrom
ASIDISG:fix/issue-281-dashboard-timestamp-staleness

Conversation

@ASIDISG

@ASIDISG ASIDISG commented Aug 31, 2026

Copy link
Copy Markdown

Fixes #281.

Problem

isStale() in apps/web/src/hooks/useDashboardData.ts compared Date.parse(fetchedAt) against nowMs using >. Date.parse() returns NaN for unparseable input, and any comparison against NaN (including >) evaluates to false in JavaScript — so a malformed or missing timestamp was silently classified as fresh instead of stale.

Fix

isStale() now:

  • Returns true (stale) for a missing/null/undefined fetchedAt.
  • Returns true (stale) when Date.parse(fetchedAt) is not finite (unparseable string).
  • Falls through to the original threshold comparison for valid timestamps, so existing fresh/stale/future behavior is unchanged.

Tests

Added apps/web/src/hooks/useDashboardData.test.ts (registered in apps/web/package.json's test script, matching this workspace's convention of listing test files explicitly):

  • Invalid/missing cases: unparseable string, empty string, garbage string, invalid calendar date, null, undefined — all stale.
  • Valid fresh and valid old-beyond-threshold cases — unchanged behavior.
  • Boundary cases: exactly at threshold (fresh), one ms past (stale), one ms inside (fresh).
  • Future-timestamp case confirmed still fresh (pre-existing behavior preserved).

Verification

  • tsc --noEmit -p tsconfig.json — clean.
  • Full apps/web test suite (node --import tsx --test ...) — 56/56 passing, no regressions.

Date.parse() returns NaN for unparseable input, and every comparison
against NaN (including >) evaluates to false in JavaScript. Without an
explicit check, a malformed or missing fetchedAt would silently be
reported as fresh instead of triggering the staleness warning.

isStale() now returns true for missing/null/undefined timestamps and
for strings that fail to parse, while leaving valid-timestamp
freshness behavior (including future timestamps) unchanged.
@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@ASIDISG Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@karagozemin
karagozemin merged commit b5860b9 into Sub-Rosa-Issue:main Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Treat invalid dashboard timestamps as stale

2 participants